﻿using System;
using TeachingManageSystem.BLL;
using TeachingManageSystem.Entity;

namespace TeachingManageSystem.Web
{
    public partial class ShowImage : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if(Request.QueryString["ImageID"]!=null)
            {
                try
                {
                     var pic = new Picture
                          {
                              ID=Convert.ToInt16( Request.QueryString["ImageID"])
                             
                          };
                          var getreader = PictureBll.GetPictureByID(pic);
                          if (getreader != null && getreader.HasRows)
                          {
                               //读取数据
                               while (getreader.Read())
                               {
                                   Response.ContentType = getreader["markType"] as string;
                                   // Response.BinaryWrite((byte[])getreader["Picturn"]);

                                   Response.OutputStream.Write(getreader["Picturn"] as byte[], 0, Convert.ToInt32(getreader["markSize"]));
                                   Response.End();
                                }
                           }
                }
                catch (Exception)
                {

                }
            }
            else
            {
                if(Session["Image"]!=null)
                {
                    var pic = (Picture) Session["Image"];
                    Response.BinaryWrite(pic.Picturn);
                }
            }
           

        }
    }
}